//剑指28：判断是否为一棵对称二叉树
class Solution {

    public boolean recursion(TreeNode leftTree, TreeNode rightTree){
        if(leftTree==null && rightTree==null) return true;
        if(leftTree==null && rightTree!=null) return false;
        if(leftTree!=null && rightTree==null) return false;
        if(leftTree.val == rightTree.val){
            return recursion(leftTree.left, rightTree.right) && recursion(leftTree.right, rightTree.left);
        }
        return false;
    } 

    public boolean isSymmetric(TreeNode root) {
        if(root==null) return true;
        return recursion(root.left, root.right);
    }
}